﻿@{
    ViewBag.Title = "积分设置";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutCMS.cshtml";
} 
 
@section htmlhead{
    <link href="~/Content/assets/css/Layout/css/main.css" rel="stylesheet" />
    <link href="~/Content/assets/css/plugin/xjgrid.css" rel="stylesheet" />
}
<div class="container">

    <h2>@ViewBag.Title</h2>
    <div id="table" class="mt10">
        <div id="button" class="mt10">
            <form id="formQuery" class="form-inline" role="form">
                <input type="text" name="SettingName" class="input-text lh25" size="45" placeholder="输入名称">
                <input type="button" id="btnSearch" name="button" class="btn btn82 btn_search" value="查询">
                
                <input type="button" id="btnAdd" name="button" class="btn btn82 btn_add" value="新增">
            </form>
        </div>
        <div class="box span10 oh">
            <div id="gridlist">
            </div>
        </div>
    </div>
</div>
@section jssection{
    <script type="text/javascript">
        var util = {};
        var options = {
            listUrl: "@Url.Action("ScoreSettingList")",
            editUrl: "@Url.Action("ScoreSettingEdit")", 
        }; 
    </script> 
    <script src="~/Content/assets/plugins/xjgrid/xjgrid.js"></script>
    <script src="~/Content/assets/layer/layer.min.js"></script> 
    <script>
        ; (function (window, undefined, $) { 
            $(document).ready(function () { 
                var gridopt = {
                    url: options.listUrl,
                    colModel: [
                            { display: '编号', name: 'Id', width: "3%", sortable: true, hide: true, align: 'left', iskey: true },
                            { display: '积分规则', name: 'Name', width: "7%", sortable: false, align: 'left' },
                            { display: '获取积分', name: 'extcredits1', width: "7%", sortable: false, align: 'left' },  
                            { display: '操作', name: 'Id', width: "7%", sortable: false, align: 'center', process: processOp }
                    ],
                    sortname: "Id",
                    sortorder: "ASC",
                    title: false,
                    rp: 15,
                    usepager: true,
                    showcheckbox: false
                };
                var xjgrid = new xjGrid("gridlist", gridopt);
                function processOp(value, cell) {
                    var ops = [];
                    ops.push("&nbsp;<a title='编辑' href='javascript:;'  onclick=\"util.Edit('", value, "')\"><i class='fa fa-edit' ></i>编辑</a>");
                 
                    return ops.join("");
                } 
                $("#formQuery").submit(function () {
                    xjgrid.Query(this);
                    return false;
                });
                $("#btnSearch").click(function () {
                    $("#formQuery").submit();
                });
                $("#btnAdd").click(function (e) {
                    var url = options.editUrl;
                    location.href = url;
                });
          
                util.Edit = function (id) { 
                    var url = options.editUrl + "/" + id;
                    location.href = url;
                }; 
                util.Delete = function (id, name) {
                    if (!confirm("您确定要执行删除操作吗？")) {
                        return false;
                    }
                    $.post(options.deleteUrl + "/" + id, { id: id },
                          function (res) {
                              if (res.Status > 0) {
                                  alert("操作成功！");
                                  xjgrid.Reload();
                              }
                              else {
                                  alert("操作失败！");
                              }
                          },
                          "json"
                    );
                };
            });

        })(window, undefined, jQuery);
    </script>
}

